package org.geektimes.context.listener;


import org.geektimes.context.ClassicComponentContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.logging.Logger;

public class ComponentContextInitializerListener implements ServletContextListener {
    private static final Logger logger = Logger.getLogger(ComponentContextInitializerListener.class.getName());

    @Override
    public void contextInitialized(ServletContextEvent sce) throws RuntimeException {
        logger.info("ComponentContextInitializerListener");
        ServletContext servletContext = sce.getServletContext();
        ClassicComponentContext context = new ClassicComponentContext();
        context.init(servletContext);
    }
    @Override

    public void contextDestroyed(ServletContextEvent sce) {
        ClassicComponentContext context = ClassicComponentContext.getInstance();
        context.destroy();
    }
}
